package com.flex.util.events {

import flash.events.Event;

[SDK]
public class MethodReturnEvent extends Event {
   private var _result:Object;
   private var _error:Error;
   private var _callContext:Object;
   private var _callee:Object;

   public static const DEFAULT_RETURN_ID:String = "methodReturn";

   [Result]
   public function get result():Object {
      return _result;
   }

   [Error]
   public function get error():Error {
      return _error;
   }

   public function get callContext():Object {
      return _callContext;
   }

   public function get callee():Object {
      return _callee;
   }

   public function MethodReturnEvent( result:Object, error:Error,
                                      callContext:Object = null, callee:Object = null,
                                      eventId:String = DEFAULT_RETURN_ID ) {
      super( eventId );
      _result = result;
      _error = error;
      _callContext = callContext;
      _callee = callee;
   }

   public static function newResultEvent( result:Object, callContext:Object = null,
                                          callee:Object = null ):MethodReturnEvent {
      return new MethodReturnEvent( result, null, callContext, callee );
   }

   public static function newErrorEvent( error:Error, callContext:Object = null,
                                         callee:Object = null ):MethodReturnEvent {
      return new MethodReturnEvent( null, error, callContext, callee );
   }

   public override function clone():Event {
      return new MethodReturnEvent( result, error, callContext, callee, type );
   }
}
}